#!/bin/bash
# Subversion pre-commit hook.
# This kook rejects all commits while repositories are synchronazing.
#
# Expected arguments:
# $1 - Path to svn repository.
# $2 - Name of the user attempting to commit.

SVN_REPO_DIR="$1"
SVN_USERNAME="$2"
SCRIPT_PATH=${SCRIPT_PATH:-"$0"}
SYNC_LOCK="$1/svncc/sync.lock"

if [ "$OSTYPE" == "cygwin" ]
then
    SCRIPT_PATH=`cygpath -a "$SCRIPT_PATH"`
    SYNC_LOCK=`cygpath -a "$SYNC_LOCK"`
fi

. "`dirname "$SCRIPT_PATH"`/common.sh"

if [[ -e "$SYNC_LOCK" && "$SYNC_USERNAME" != "$SVN_USERNAME" ]]
then
    echo "$SYNC_REJECT_COMMIT_MESSAGE" 1>&2
    exit 1
fi
